﻿using System;
using System.Collections.Generic;
using System.Web;
using NExt.grid;
using NExt.data;
using NExt.UI.Base.Js;

namespace NExt.Demo.Application.Entity2
{
    public class Browse : global::NExt.UI.Browse.Data.GridBrowsePresenter
    {
        protected override ColumnModel BuildColumnModel()
        {
            ColumnModel columnModel = new ColumnModel();
            columnModel.defaultSortable = true;
            columnModel.columns.Add(new RowNumberer());
            columnModel.columns.Add(new Column() { header = "Company", width = 120, sortable = true, dataIndex = "company" });
            columnModel.columns.Add(new Column() { header = "Price", width = 70, sortable = true, dataIndex = "price", renderer = NExt.util.Format.usMoney });
            columnModel.columns.Add(new Column() { header = "Change", width = 70, sortable = true, dataIndex = "change" });
            columnModel.columns.Add(new Column() { header = "% Change", width = 70, sortable = true, dataIndex = "pctChange" });

            return columnModel;
        }

        protected override DataReader BuildReader()
        {
            Record record = new Record();
            record.fields.Add(new FieldDefinition() { name = "company", type = FieldDefinitionType.auto, sortDir = SortDirection.ASC });
            record.fields.Add(new FieldDefinition() { name = "price", type = FieldDefinitionType.floatt });
            record.fields.Add(new FieldDefinition() { name = "change", type = FieldDefinitionType.floatt });
            record.fields.Add(new FieldDefinition() { name = "pctChange", type = FieldDefinitionType.floatt });

            ArrayReader reader = new ArrayReader();
            reader.recordType = record;

            return reader;
        }

        public string Test()
        {
            return "test";
        }
    }
}
